SET(AI ai)
SET(ANIM anim)
SET(GAMESYS gamesys)
SET(PHYSICS physics)
SET(SCRIPT script)

SET(GAME_LIST
    ${AI}/AAS.cpp
    ${AI}/AAS_debug.cpp
    ${AI}/AAS_pathing.cpp
    ${AI}/AAS_routing.cpp
    ${AI}/AI.cpp
    ${AI}/AI_events.cpp
    ${AI}/AI_pathing.cpp
    ${AI}/AI_Vagary.cpp
    ${ANIM}/Anim.cpp
    ${ANIM}/Anim_Blend.cpp
    ${ANIM}/Anim_Import.cpp
    ${ANIM}/Anim_Testmodel.cpp
    ${GAMESYS}/Class.cpp
    ${GAMESYS}/DebugGraph.cpp
    ${GAMESYS}/Event.cpp
    ${GAMESYS}/SaveGame.cpp
    ${GAMESYS}/SysCmds.cpp
    ${GAMESYS}/SysCvar.cpp
    ${GAMESYS}/TypeInfo.cpp
    ${PHYSICS}/Clip.cpp
    ${PHYSICS}/Force.cpp
    ${PHYSICS}/Force_Constant.cpp
    ${PHYSICS}/Force_Drag.cpp
    ${PHYSICS}/Force_Field.cpp
    ${PHYSICS}/Force_Spring.cpp
    ${PHYSICS}/Physics.cpp
    ${PHYSICS}/Physics.cpp
    ${PHYSICS}/Physics_Actor.cpp
    ${PHYSICS}/Physics_AF.cpp
    ${PHYSICS}/Physics_Base.cpp
    ${PHYSICS}/Physics_Monster.cpp
    ${PHYSICS}/Physics_Parametric.cpp
    ${PHYSICS}/Physics_Player.cpp
    ${PHYSICS}/Physics_RigidBody.cpp
    ${PHYSICS}/Physics_Static.cpp
    ${PHYSICS}/Physics_StaticMulti.cpp
    ${PHYSICS}/Push.cpp
    ${SCRIPT}/Script_Compiler.cpp
    ${SCRIPT}/Script_Interpreter.cpp
    ${SCRIPT}/Script_Program.cpp
    ${SCRIPT}/Script_Thread.cpp
    Actor.cpp
    AF.cpp
    AFEntity.cpp
    BrittleFracture.cpp
    Camera.cpp
    Entity.cpp
    Fx.cpp
    Game_local.cpp
    Game_network.cpp
    GameEdit.cpp
    IK.cpp
    Item.cpp
    Light.cpp
    Misc.cpp
    Moveable.cpp
    Mover.cpp
    MultiplayerGame.cpp
    Player.cpp
    PlayerIcon.cpp
    PlayerView.cpp
    Projectile.cpp
    Pvs.cpp
    SecurityCamera.cpp
    SmokeParticles.cpp
    Sound.cpp
    Target.cpp
    Trigger.cpp
    Weapon.cpp
    WorldSpawn.cpp
    Game.def
)

set(INCLUDE_LIST
    ${AI}/AAS.h
    ${AI}/AAS_local.h
    ${AI}/AI.h
    ${ANIM}/Anim.h
    ${ANIM}/Anim_Testmodel.h
    ${GAMESYS}/Class.h
    ${GAMESYS}/DebugGraph.h
    ${GAMESYS}/Event.h
    ${GAMESYS}/NoGameTypeInfo.h
    ${GAMESYS}/SaveGame.h
    ${GAMESYS}/SysCmds.h
    ${GAMESYS}/SysCvar.h
    ${PHYSICS}/Clip.h
    ${PHYSICS}/Force.h
    ${PHYSICS}/Force_Constant.h
    ${PHYSICS}/Force_Drag.h
    ${PHYSICS}/Force_Field.h
    ${PHYSICS}/Force_Spring.h
    ${PHYSICS}/Physics.h
    ${PHYSICS}/Physics_Actor.h
    ${PHYSICS}/Physics_AF.h
    ${PHYSICS}/Physics_Base.h
    ${PHYSICS}/Physics_Monster.h
    ${PHYSICS}/Physics_Parametric.h
    ${PHYSICS}/Physics_Player.h
    ${PHYSICS}/Physics_RigidBody.h
    ${PHYSICS}/Physics_Static.h
    ${PHYSICS}/Physics_StaticMulti.h
    ${PHYSICS}/Push.h
    ${SCRIPT}/Script_Compiler.h
    ${SCRIPT}/Script_Interpreter.h
    ${SCRIPT}/Script_Program.h
    ${SCRIPT}/Script_Thread.h
    Actor.h
    AF.h
    AFEntity.h
    BrittleFracture.h
    Camera.h
    Entity.h
    Fx.h
    Game.h
    Game_local.h
    GameEdit.h
    IK.h
    Item.h
    Light.h
    Misc.h
    Moveable.h
    Mover.h
    MultiplayerGame.h
    Player.h
    PlayerIcon.h
    PlayerView.h
    Projectile.h
    Pvs.h
    SecurityCamera.h
    SmokeParticles.h
    Sound.h
    Target.h
    Trigger.h
    Weapon.h
    WorldSpawn.h
)

ADD_DEFINITIONS(
    -D__DOOM__
    -DGAME_DLL
)

if (UNIX)
    ADD_DEFINITIONS(-fPIC)
endif (UNIX)

if (APPLE)
    ADD_DEFINITIONS(-m32)
ENDIF (APPLE)

ADD_LIBRARY(game SHARED ${GAME_LIST})
TARGET_LINK_LIBRARIES(game idlib)
SET_TARGET_PROPERTIES(game PROPERTIES SUFFIX "x86")

IF (APPLE)
    TARGET_LINK_LIBRARIES(game -m32)
ENDIF (APPLE)

install(TARGETS game DESTINATION ${CMAKE_INSTALL_PREFIX}/base)
